package com.zbl.zblproject.erp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2018/10/10
 * 出入库单实体类
 */
@TableName("zbl_erp_order")
public class ErpOrder {


    @TableId(type = IdType.AUTO)
    private int orderId;

    /**
     * 出入库单号
     */
    @NotNull
    @NotEmpty
    private String orderInfo;

    /**
     * 操作人
     */
    @NotNull
    @NotEmpty
    private String operator;

    /**
     * 创建订单时间
     */
    private LocalDateTime createTime;


    /**
     * 订单状态
     * 0:草稿 1:提交申请 2:通过
     */
    private int status;


    /**
     * 出入库模式
     * 0: 入库  1: 出库
     * 2: 盘库  3：报损
     * 4: 领用  5: 退货
     */
    private int mode;

    /**
     * 执行人
     */
    private String executor;

    /**
     * 执行时间
     */
    private LocalDateTime executeTime;

    /**
     * 内置仓库订单
     */
    @TableField(exist = false)
    @JsonIgnore
    private ErpInventoryOrder erpInventoryOrder;

    /**
     * 门店ID
     */
    private int storeId;

    /**
     * 门店名称
     */
    @TableField(exist = false)
    private String storeName;

    /**
     * 原始数据
     */
    private String originOrderSn;

    /**
     * 查询名称
     */
    private String searchName;

    /**
     * 订单备注
     */
    private String context;

    /**
     * 合计金额
     */
    @TableField(exist = false)
    private String total;

    /**
     * 品牌名称
     */
    private String brandName;

    /**
     * 供应商名称
     */
    private String supplierName;

    /**
     * 货运单图片地址
     */
    private String freightPath;

    /**
     *物流费用比率
     * @return
     */
    private BigDecimal logisticsCostRatio;


    public ErpOrder(){ }

    /**
     * 类型转化
     * @param order
     */
    public ErpOrder(ErpInventoryOrder order){
        this.orderId = 0 - order.getId();
        this.orderInfo = order.getInventorySn();
        this.operator = order.getOperator();
        this.createTime = order.getCreateTime();
        this.status = order.getStatus();
        this.mode  = order.getMode() + 2;
    }

    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    public String getOrderInfo() {
        return orderInfo;
    }

    public void setOrderInfo(String orderInfo) {
        this.orderInfo = orderInfo;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }


    public String getExecutor() {
        return executor;
    }

    public void setExecutor(String executor) {
        this.executor = executor;
    }

    public LocalDateTime getExecuteTime() {
        return executeTime;
    }

    public void setExecuteTime(LocalDateTime executeTime) {
        this.executeTime = executeTime;
    }


    public ErpInventoryOrder getErpInventoryOrder() {
        return erpInventoryOrder;
    }

    public void setErpInventoryOrder(ErpInventoryOrder erpInventoryOrder) {
        this.erpInventoryOrder = erpInventoryOrder;
    }

    public int getStoreId() {
        return storeId;
    }

    public void setStoreId(int storeId) {
        this.storeId = storeId;
    }

    public String getOriginOrderSn() {
        return originOrderSn;
    }

    public void setOriginOrderSn(String originOrderSn) {
        this.originOrderSn = originOrderSn;
    }

    public String getSearchName() {
        return searchName;
    }

    public void setSearchName(String searchName) {
        this.searchName = searchName;
    }

    public String getContext() {
        return context;
    }

    public void setContext(String context) {
        this.context = context;
    }

    public String getTotal() {
        return total;
    }

    public void setTotal(String total) {
        this.total = total;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getBrandName() {
        return brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public ErpOrderStatus getOrderStatus(){
        return ErpOrderStatus.valueOf(this.status);
    }

    public void setOrderStatus(ErpOrderStatus erpOrderStatus){
        this.status = erpOrderStatus.getStatus();
    }


    public String getFreightPath() {
        return freightPath;
    }

    public void setFreightPath(String freightPath) {
        this.freightPath = freightPath;
    }


    @Override
    public String toString() {
        return "ErpOrder{" +
                "orderId=" + orderId +
                ", orderInfo='" + orderInfo + '\'' +
                ", operator='" + operator + '\'' +
                ", createTime=" + createTime +
                ", status=" + status +
                ", mode=" + mode +
                ", executor='" + executor + '\'' +
                ", executeTime=" + executeTime +
                '}';
    }

    public BigDecimal getLogisticsCostRatio() {
        return logisticsCostRatio;
    }

    public void setLogisticsCostRatio(BigDecimal logisticsCostRatio) {
        this.logisticsCostRatio = logisticsCostRatio;
    }
}
